package com.homework3;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class Server {
    public static void main(String[] args) throws IOException {
        DatagramSocket socket = new DatagramSocket(8866, InetAddress.getLocalHost());
        byte[] data = new byte[1024];
        DatagramPacket packet = new DatagramPacket(data, data.length);
        socket.receive(packet);
        int len = packet.getLength();
        byte[] bytes = packet.getData();
        System.out.println("数据长度:"+len);
        System.out.println("接收到的数据:"+new String(data,0,len));
        socket.close();


    }
}
